<?php

/* 消费记录 */
namespace app\admin\controller;

use cmf\controller\AdminBaseController;
use think\facade\Db;

class CoinrecordController extends AdminBaseController
{
    var $type=array("0"=>"支出","1"=>"收入");
    var $action=array(
		"1"=>"赠送礼物",
		"2"=>"视频通话",
		"3"=>"语音通话",
		"4"=>"视频付费",
		"5"=>"照片付费",
		"6"=>"购买VIP",
		"7"=>"购买私信",
		"8"=>"注册奖励",
		"9"=>"直播间付费",
		"10"=>"直播间计时付费",
		"11"=>"直播间发送弹幕付费",
        "12"=>"签到奖励",
        "13"=>"新手任务-上传头像奖励",
        "14"=>" 新手任务-完善资料奖励",
        "15"=>"新手任务-实名认证奖励",
        "16"=>"新手任务-主播认证奖励",
        "17"=>"每日任务-发布动态奖励",
        "18"=>" 每日任务-点赞动态奖励",
        "19"=>"每日任务-发送私信奖励",
        "20"=>"每日任务-语音通话奖励",
        "21"=>"每日任务-视频通话奖励",
        "22"=>"每日任务-开启直播奖励",
		);
        
    public function index()
    {
        
        $data = $this->request->param();
        $map=[];
		
		$type=isset($data['type']) ? $data['type']: '';
        if($type!=''){
            $map[]=['type','=',$type];
        }
		
		
		$action=isset($data['action']) ? $data['action']: '';
        if($action!=''){
            $map[]=['action','=',$action];
        }

        $start_time=isset($data['start_time']) ? $data['start_time']: '';
        $end_time=isset($data['end_time']) ? $data['end_time']: '';
        if($start_time!=""){
           $map[]=['addtime','>=',strtotime($start_time)];
        }
        if($end_time!=""){
           $map[]=['addtime','<=',strtotime($end_time) + 60*60*24];
        }

        $uid=isset($data['uid']) ? $data['uid']: '';
        if($uid!=''){
            $map[]=['uid','=',$uid];
        }
        
        $this->giftlist=Db::name('gift')->column('name','id');
        
        $list = Db::name('user_coinrecord')
            ->where($map)
            ->order("id desc")
            ->paginate(20);
        
        $list->each(function($v,$k){
           $v['userinfo']= getUserInfo($v['uid']);
           
           $action=$v['action'];
           switch($action){
                case '1':
                   
					$info=Db::name("gift")->field("name")->where("id='{$v['actionid']}'")->find();
					if(!$info){
						$info=[];
						$info['name']='礼物已删除';
					}
					
                   
                    $v['name']=$info['name'].'('.$v['actionid'].')';
                    break;
                case '2':
                    $v['name']='视频通话';
                    break;
                case '3':
                    $v['name']='语音通话';
                    break;
                case '4':
                    $v['name']='视频付费'.'('.$v['actionid'].')';
                    break;
                case '5':
                    $v['name']='照片付费'.'('.$v['actionid'].')';
                    break;
                case '6':
                    $v['name']='购买VIP';
                    break;
                case '7':
                    $v['name']='购买私信';
                    break;
                case '8':
                    $v['name']='注册奖励';
                    break;
				case '9':
                    $v['name']='直播间付费';
                    break;
				case '10':
                    $v['name']='直播间计时付费';
                    break;
				case '11':
                    $v['name']='直播间发送弹幕付费';
                    break;
                case '12':
                    $v['name']='签到奖励';
                    break;
                case '13':
                    $v['name']=' 新手任务-上传头像奖励';
                    break;
                case '14':
                    $v['name']='新手任务-完善资料奖励';
                    break;
                case '15':
                    $v['name']='新手任务-实名认证奖励';
                    break;
                case '16':
                    $v['name']=' 新手任务-主播认证奖励';
                    break;
                case '17':
                    $v['name']='每日任务-发布动态奖励';
                    break;
                case '18':
                    $v['name']='每日任务-点赞动态奖励';
                    break;
                case '19':
                    $v['name']='每日任务-发送私信奖励';
                    break;
                case '20':
                    $v['name']='每日任务-语音通话奖励';
                    break;
                case '21':
                    $v['name']='每日任务-视频通话奖励';
                    break;
                case '22':
                    $v['name']='每日任务-开启直播奖励';
                    break;
                
           }
           
           return $v; 
        });
        
        $list->appends($data);
        
        $page = $list->render();
        $this->assign("page", $page);
            
        $this->assign('list', $list);
        $this->assign('type', $this->type);
        $this->assign('action', $this->action);

        return $this->fetch();
    }

}